package com.cloud.code.真题;

import java.util.Arrays;
import java.util.Scanner;

public class Demo1 {


    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        while (scanner.hasNext()) {

            int n = Integer.parseInt(scanner.nextLine());
            int[] nums = new int[n];

            for (int i = 0; i < n; i++) {
                nums[i] = scanner.nextInt();
            }

            int tem = 0;

            for (int i = 0; i < n; i++) {
                tem = tem^nums[i];
            }
            Arrays.sort(nums);
            if(tem == 0){

                int sum = 0;
                for (int i = 1; i < n; i++) {
                    sum = sum + nums[i];
                }

                System.out.println(sum);

            }else {
                System.out.println(-1);
            }

        }

    }
}
